package com.zzh.wxdemo.utils;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import com.zzh.wxdemo.base.MyApp;

public class SysytemUtils {

    public static String getIMEI(Context context) {
        TelephonyManager tm = (TelephonyManager) MyApp.mContext.getSystemService(Context.TELEPHONY_SERVICE);
        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
            String imei = tm.getDeviceId();
            return TextUtils.isEmpty(imei) ? "" : imei;
        } else {
            ToastUtil.show("没有获取手机卡信息的权限");
        }
        return "";
    }


}
